package main

import (
	"fmt"
	"io/fs"
	"os"
	"path/filepath"
)

func deleteFilesInDir(dir string) error {
	err := filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error {
		if err != nil {
			return err
		}
		if !d.IsDir() {
			fmt.Printf("Deleting file: %s\n", path)
			err := os.Remove(path)
			if err != nil {
				return fmt.Errorf("failed to delete file %s: %w", path, err)
			}
		}
		return nil
	})
	return err
}

func main() {
	// 替换为你要删除文件的目录路径
	directory := "/go111/1122"
	err := deleteFilesInDir(directory)
	if err != nil {
		fmt.Printf("Error: %v\n", err)
	} else {
		fmt.Println("Files deleted successfully.")
	}
}
